package com.im.controller;

import com.im.service.busiConst.smo.IBusiConstQuerySmo;
import com.im.service.dto.BusiConstParam;
import com.im.service.dto.BusiConstParamVal;
import com.im.service.model.BusiConstVo;
import com.im.util.ReturnsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;

@RestController
@RequestMapping("/busiConstService")
public class BusiConstService {

    @Autowired
    private IBusiConstQuerySmo busiConstQuerySmo;

    @PostMapping(value = "/queryBusiConstList")
    public String queryBusiConstList(@RequestBody BusiConstVo busiConstVo) throws Exception {
        List<BusiConstParam> list=busiConstQuerySmo.queryBusiConstParam(busiConstVo);
        if(CollectionUtils.isEmpty(list)){
           return ReturnsUtil.returnFailure("未查询到常量信息");
        }
        BusiConstParam busiConstParam=list.get(0);
        busiConstVo.setConstParamId(busiConstParam.getConstParamId());
        List<BusiConstParamVal> result= busiConstQuerySmo.queryBusiConstParamVal(busiConstVo);
        return ReturnsUtil.returnSuccess(result).toString();
    }
}
